package com.ruoyi.web.controller.snmp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SnmpGroupinfo;
import com.ruoyi.system.service.ISnmpGroupinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *  Controller
 *
 * @author ruoyi
 * @date 2025-02-05
 */
@RestController
@RequestMapping("/snmp/groupinfo")
public class SnmpGroupinfoController extends BaseController
{
    @Autowired
    private ISnmpGroupinfoService snmpGroupinfoService;

    /**
     * 查询 】列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:groupinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SnmpGroupinfo snmpGroupinfo)
    {
        startPage();
        List<SnmpGroupinfo> list = snmpGroupinfoService.selectSnmpGroupinfoList(snmpGroupinfo);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('snmp:groupinfo:list')")
    @GetMapping("/allist")
    public AjaxResult allist(SnmpGroupinfo snmpGroupinfo)
    {
        List<SnmpGroupinfo> list = snmpGroupinfoService.selectSnmpGroupinfoList(snmpGroupinfo);
        return success(list);
    }
    /**
     * 导出 列表
     */
    @PreAuthorize("@ss.hasPermi('snmp:groupinfo:export')")
    @Log(title = " ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SnmpGroupinfo snmpGroupinfo)
    {
        List<SnmpGroupinfo> list = snmpGroupinfoService.selectSnmpGroupinfoList(snmpGroupinfo);
        ExcelUtil<SnmpGroupinfo> util = new ExcelUtil<SnmpGroupinfo>(SnmpGroupinfo.class);
        util.exportExcel(response, list, " 数据");
    }

    /**
     * 获取 详细信息
     */
    @PreAuthorize("@ss.hasPermi('snmp:groupinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(snmpGroupinfoService.selectSnmpGroupinfoById(id));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('snmp:groupinfo:add')")
    @Log(title = " ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SnmpGroupinfo snmpGroupinfo)
    {
        return toAjax(snmpGroupinfoService.insertSnmpGroupinfo(snmpGroupinfo));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('snmp:groupinfo:edit')")
    @Log(title = " ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SnmpGroupinfo snmpGroupinfo)
    {
        return toAjax(snmpGroupinfoService.updateSnmpGroupinfo(snmpGroupinfo));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('snmp:groupinfo:remove')")
    @Log(title = " ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(snmpGroupinfoService.deleteSnmpGroupinfoByIds(ids));
    }
}
